
export function request (config) {
    // 判断 url中是否带有 /my/ 请求的是私有的路径 带上header token
    let header={...config.header};
    if(config.url.includes("/my/")){
      // 拼接header 带上token
      header["Authorization"]=wx.getStorageSync("token");
    }

  return new Promise((resolve, reject) => {
     let baseURL = 'https://api-hmugo-web.itheima.net/api/public/v1'
     wx.request({
      ...config,
      url: baseURL + config.url,
      // data: config.data,
      // method: config.method,
      header:header,
      success: (res)=>{
        resolve(res.data)
      },
      fail: (err)=>{
        reject(err)
      },
      complete: ()=>{}
    });
  }) 
}